<?php include show_tpl('public_uheader.htm'); ?>

<div style="width:100%; height:20px; background:#E9ECF3;"></div>

<?php include show_tpl('public_usider.htm'); ?>

<div id="page-wrapper" class="gray-bg">

	<div class="row wrapper wrapper-content">
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="panel-title">
							<em class="fa fa-list"></em>
							收款信息
							<span style="margin-top:-20px;margin-bottom:20px;text-align:center;font-size:12px;color:#666">
								
							</span>
						</div>
					</div>
					<div class="panel-body">
						<div class="table-responsive">
							<table class="table table-bordered text-center">
								<thead class="thead">
									<tr>
										<th>银行名称</th>
										<th>银行帐号</th>
										<th>姓名</th>
									</tr>
								</thead>
								<tbody>
									<?php foreach($bank as $b){ ?>
									<tr>
										<td><?php echo $b['bank'];?></td>
										<td><?php echo $b['code'];?></td>
										<td><?php echo $b['name'];?></td>
									</tr>
									<?php } ?>
								</tbody>
							</table>
						</div>	
						<?php if(count($bank)<$conf['bank_card_max']){ ?>
						<button class="btn btn-primary" id="add">添加新的收款帐号</button>
						<?php } ?>
					</div>  
				</div>
			</div>
		</div>
	</div>
</div>

<?php include show_tpl('public_ufooter.htm'); ?>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">添加新的银行卡</h4>
            </div>
            <div class="modal-body">
				<div class="content-box">
					<form action="<?php echo url('user-bank');?>" method="POST" id="addForm" class="form-horizontal">
						<div class="form-group">
							<label class="col-md-3 control-label">银行名称：</label>
							<div class="col-lg-8">
								<select name="bank" class="form-control">
									<?php foreach($conf['bank'] as $_bank){ ?>
									<option><?php echo $_bank;?></option>
									<?php } ?>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-md-3 control-label">银行卡号：</label>
							<div class="col-lg-8">
								<input type="text" name="code" class="form-control"> 
							</div>
						</div>
						<div class="form-group">
							<label class="col-md-3 control-label">姓名：</label>
							<div class="col-lg-8">
								<input type="text" name="name" class="form-control"> 
							</div>
						</div>
					</form>
				</div>
			</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="addSubmit">提交</button>
            </div>
        </div>
    </div>
</div>

<script>
	
	$('#add').click(function(){
		$('#myModal').modal('show');
	});

	$('#addSubmit').click(function(){
		var $this = $('#submit');
		$this.attr('disabled', '1');
		var postdata = $('#addForm').serialize();
		$.post($('#addForm').attr('action'), postdata, function(message){
			alert(message.message);
			if(message.code==1) window.location.reload();
			$this.attr('disabled', false);
		}, 'json');
		return false;
	});

</script>